/*
 * @Author: wjk
 * @Date: 2020-01-03 11:37:21
 * @LastEditors  : wjk
 * @LastEditTime : 2020-01-06 15:11:44
 * @description: 登录接口
 */
import request from '@/utils/request'
import requestNew from '@/utils/request'

export async function globalRegion(params) {
  const res = await request({
    url: '/global-region',
    method: 'post',
    data: params || {}
  })
  return res
}
export async function getMobileRegion(params) {
  const res = await request({
    url: '/mobile-region',
    method: 'post',
    data: params || {}
  })
  return res
}

export async function sendSms(countryCode, phoneNumber) {
  const res = await request({
    url: '/sms/send',
    method: 'post',
    data: {
      region_code: countryCode,
      mobile: phoneNumber
    }
  })
  return res
}

// 幼儿园验证码
export async function kinderSendSms(countryCode, phoneNumber) {
  const res = await requestNew({
    url: '/schoolActivity/sms/send',
    headers: {
      'Content-Type': 'application/json'
    },
    method: 'post',
    data: {
      region_code: countryCode,
      mobile: phoneNumber
    }
  })
  return res
}

export async function mobileLogin(params) {
  const res = await request({
    url: '/login/mobile',
    method: 'post',
    data: params || {}
  })
  return res
}

/**
 * @Author: wjk
 * @Date: 2020-01-04 16:57:16
 * @LastEditors: wjk
 * @description: 微信登录
 * @param {code} 微信code
 * @return: 用户信息
 */
export async function wechatLogin(params) {
  const res = await request({
    url: '/mini-program/wx',
    method: 'post',
    data: params || {}
  })
  return res
}

/**
 * @Author: wjk
 * @Date: 2020-01-04 16:57:16
 * @LastEditors: wjk
 * @description: 微信登录
 * @param {code} 微信code
 * @return: 用户信息
 */
export async function wechatBind(params) {
  const res = await request({
    url: '/gzh/bind',
    method: 'post',
    data: params || {}
  })
  return res
}
